- name: put infra repos into yum.repos.d
  copy: src=files/dnf/infra-tags.repo dest=/etc/yum.repos.d

- name: put infra stg repos into yum.repos.d if staging
  copy: src=files/dnf/infra-tags-stg.repo dest=/etc/yum.repos.d
  when:
    - network_name == "coprdev-net"
    - not prepare_base_image

- name: disable updates-testing
  file:
    path: /etc/yum.repos.d/fedora-updates-testing.repo
    state: absent

- shell: dnf -y upgrade
  when: prepare_base_image

- name: set bigger timeout for yum
  ini_file: dest=/etc/yum.conf section=main option=timeout value=1000

- name: set bigger timeout for dnf
  ini_file: dest=/etc/dnf/dnf.conf section=main option=timeout value=1000

- name: install pkgs
  dnf: state=present pkg={{ item }}
  with_items:
    - dnf
    - dnf-plugins-core
    - mock
    - yum-utils
    - pyliblzma
    - rsync
    - openssh-clients
    - libselinux-python
    - libsemanage-python
    - yum
    - scl-utils-build
    - ethtool
    - expect

- name: enable @copr/copr-dev in staging
  command: dnf copr -y enable @copr/copr-dev
  when:
    - network_name == "coprdev-net"
    - not prepare_base_image

- name: clean dnf cache
  shell: dnf clean all

- name: make sure newest rpm
  dnf: state=latest pkg={{ item }}
  with_items:
    - rpm
    - glib2
    - ca-certificates
    - mock
    - mock-core-configs
    - dnf
    - copr-rpmbuild
    - rpkg
    - nosync
    - distribution-gpg-keys

- name: put updated mock configs into /etc/mock
  copy: src=files/mock/ dest=/etc/mock

- name: put copr-rpmbuild configuration file in the right place
  copy: src=files/main.ini dest=/etc/copr-rpmbuild/main.ini

- name: put rpkg configuration file in the right place
  copy: src=files/rpkg.conf dest=/etc/rpkg.conf

- name: mockbuilder user
  user: name=mockbuilder groups=mock

- name: mockbuilder .ssh
  file: state=directory path=/home/mockbuilder/.ssh mode=0700 owner=mockbuilder group=mockbuilder

- name: mockbuilder authorized_keys
  authorized_key: user=mockbuilder key='{{ lookup('file', '/home/copr/provision/files/buildsys.pub') }}'

- name: root authorized_keys
  authorized_key: user=root key='{{ lookup('file', '/home/copr/provision/files/buildsys.pub') }}'

- lineinfile: dest=/etc/security/limits.conf line="* soft nofile 10240" insertafter=EOF
- lineinfile: dest=/etc/security/limits.conf line="* hard nofile 10240" insertafter=EOF

- name: disable core dumps
  ini_file: dest=/etc/systemd/coredump.conf section=Coredump option=Storage value=none

- name: 'Remove %_install_langs from /etc/rpm/macros.image-language-conf'
  lineinfile:
    dest: '/etc/rpm/macros.image-language-conf'
    regexp: '^%_install_lang.*'
    state: 'absent'

- name: Disable DNF makecache timer
  systemd:
    name: dnf-makecache.timer
    state: stopped
    enabled: no

- name: Disable DNF makecache service
  systemd:
    name: dnf-makecache.service
    state: stopped
    enabled: no
